package com.sdy.common.model;

/**
 * api中使用的分页工具
 * @author zhouziqiang
 */
public class PageQuery {
    private static final long DEFAULT_PAGE_SIZE = 10;
    /**
     * 每页显示条数，默认 10
     */
    private long size = DEFAULT_PAGE_SIZE;
    /**
     * 当前页
     */
    private long current = 1;
    
    public PageQuery() {
    }

    public PageQuery(long current) {
        this.current = current;
        normalize();
    }
    
    public PageQuery(long current, long size) {
        this.current = current;
        this.size = size;
        normalize();
    }

    public void setCurrent(long current) {
        this.current = current;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public long getCurrent() {
        return this.current;
    }
    
    public long getSize() {
        return this.size;
    }

    protected void normalize() {
        if (this.current <= 0) {
            this.current = 1;
        }
        if (this.size <= 0) {
            this.size = DEFAULT_PAGE_SIZE;
        }
    }
}
